package com.briup.hdfs;

import org.apache.hadoop.io.*;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * TODO
 *
 * @author 最美如初
 * @version 1.0
 * @date 2021/7/19
 * @description
 */
public class Writable_test {
    public void NullWritable_test(){
        //null
        NullWritable nw = NullWritable.get();
    }
    public void IntWritable_test(){
        IntWritable iw = new IntWritable(12);
        IntWritable iw1 = new IntWritable();
        iw1.set(23);
        //多次赋值覆盖效果
        iw1.set(33);
        int i = iw1.get();
    }
    public void Text_test(){
        Text t = new Text("cw");
        Text t1 = new Text();
        t1.set("hello");
        //将Text类型转化为字符串
        t1.toString();
    }
    public void ArrayWritable_test(){
        String[] str={"zhangsan","lisi"};
        ArrayWritable aw = new ArrayWritable(str);

        ArrayWritable aw1 = new ArrayWritable(Student.class);
        Writable[] wr=new Writable[]{new Student(1,"zhangsan",20),
        new Student(2,"lisi",33)};
        aw1.set(wr);
        ArrayWritable aw2 = new ArrayWritable(Student.class, wr);
    }
    public void ArrayPrimitiveWritable_test(){
        //为八大基本数据类型服务
        ArrayPrimitiveWritable apw = new ArrayPrimitiveWritable(int.class);
        int[] arr={1,2,3};
        apw.set(arr);
    }
    public void TwoDArrayWritable_test(){
        Text[][] tx={{new Text("112")},{new Text("222"),new Text("333")},};
        TwoDArrayWritable twd1 = new TwoDArrayWritable(Text.class);
        twd1.set(tx);
        System.out.println(twd1.get());
        TwoDArrayWritable twd2 = new TwoDArrayWritable(Text.class, tx);
    }

    public static void main(String[] args) {

    }
}
